<template>
	<view>
		<simple-toolbar :title="$t('pool.walletAssets.walletAssets')"></simple-toolbar>

		<view class="pad-base table">
			<nav-tab @change-current-tab="walletAsset" @ready="walletAsset" />
			
			<el-table :data="listData" style="width: 100%">
				<el-table-column align="center" prop="wallet_name" :label="$t('pool.walletAssets.wallet')"></el-table-column>
				<el-table-column align='center' prop="coin_name" :label="$t('wallet.wallet.coin')"></el-table-column>
				<el-table-column align="center" prop="balance" :label="$t('pool.walletAssets.balance')"></el-table-column>
				<el-table-column align="center" prop="record_time" :label="$t('pool.walletAssets.record_time')"></el-table-column>
			</el-table>
		</view>
	</view>
</template>

<script>
	import {
		walletAsset
	} from "../../../js_sdk/uni-admin/assetPool.js"

	export default {
		data() {
			return {
				cacheCurrentTab: {
					coin: 1
				},
				listData: []
			}
		},
		methods: {
			async walletAsset(data) {
				this.data = data
				let query = {}
				if (data) {
					query = data
					this.cacheCurrentTab = data
				} else {
					query = this.cacheCurrentTab
				}
				let res = await walletAsset('get', query)
				this.listData = res.data
				this.listData.forEach(item => {
					item.balance = this.$utils.retain12(item.balance)
					item.record_time = this.$utils.formatDate(item.record_time)
				})
			}
		},
		onShow() {
			// this.walletAsset(this.data)
		}
	}
</script>

<style>

</style>
